<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>hide</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
 
    .show{
        width:200px;
        height:200px;
        background: aqua;
        transition: 0.5s all ease;
     }
     .hide {
         height: 0px ;
     }
</style>
<script>
    window.onload = function (){
        let btn = document.getElementById('btn');
        let box = document.getElementById('box');

        btn.addEventListener('click',function(){
            let arr = Array.from(box.classList);
            if(arr.indexOf('hide') != -1){
                box.className = 'show';
            }else{
                box.className = 'show hide';
            }
        },false);
    }
</script>
</head>

<body>
    <button id="btn">按钮</button>
    <div id="box" class="show"></div>
   
</body>
</html>